package com.beiben.myjob.controller;

import com.beiben.myjob.domain.CheckUserVo;
import com.beiben.myjob.service.MyWaitWorkService;
import com.beiben.work.process.domain.FileProcessUser;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.page.TableDataInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.text.ParseException;
import java.util.List;

/**
 * 我的待办工作Controller
 *
 * @author xgq
 * @date 2020-08-26
 */
@RestController
@RequestMapping("/myjob/wait/work")
public class MyWaitWorkController extends BaseController {

    @Autowired
    private MyWaitWorkService myWaitWorkService;

    /**
     * 待办工作-项目工作
     *
     * @param fileProcessUser
     * @return
     * @throws ParseException
     */
    @GetMapping("/project/list")
    public TableDataInfo projectList(FileProcessUser fileProcessUser) throws ParseException {
        startPage();
        List<FileProcessUser> list = myWaitWorkService.selectMyWaitWorkProjectList(fileProcessUser);
        return getDataTable(list);
    }

    /**
     * 待办工作-日常工作
     *
     * @param fileProcessUser
     * @return
     * @throws ParseException
     */
    @GetMapping("/process/list")
    public TableDataInfo processList(FileProcessUser fileProcessUser) throws ParseException {
        startPage();
        List<FileProcessUser> list = myWaitWorkService.selectMyWaitWorkList(fileProcessUser);
        return getDataTable(list);
    }

    /**
     * 查询代办工作统计
     */
    @GetMapping("/statistics")
    public AjaxResult statistics(SysUser user) {
        return AjaxResult.success(myWaitWorkService.statistics(user));
    }

    /**
     * 提交审核
     */
    @PostMapping("/submitCheck")
    public AjaxResult submitCheck(@RequestBody CheckUserVo checkUserVo) {
        // TODO: 2020/12/18  去service里处理数据转换。
        return AjaxResult.success(myWaitWorkService.submitCheck(checkUserVo));
    }
}
